package com.jing.weibo.controller.mobile;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jing.system.comm.BaseController;
import com.jing.weibo.pojo.user.UserInfo;

/**
 * 信息的Controller
 * @author jing.yue
 * @version 2012/09/21 1.0.0
 */
@Controller
public class MobileController extends BaseController {

	private static final Logger logger = Logger.getLogger(MobileController.class);

	/**
	 * 跳转到手机登录页面
	 * @param request
	 * @return
	 */
	@RequestMapping("/mobile")
	public String mobile(HttpServletRequest request, ModelMap modelMap) {
		logger.info("手机版-登录!");
		//判断是否登录
		UserInfo userInfo = getSessionUser(request);
		//登录过了则直接跳转
		if(userInfo != null) {
			return "redirect:m/main.shtml";
		}
		setSession(request, SESSION_LOGIN_TYPE, "mobile");
		return "redirect:mobile/login.jsp";
	}

	/**
	 * 跳转到手机登录成功的页面
	 * @param request
	 * @return
	 */
	@RequestMapping("/m/main")
	public String main(HttpServletRequest request, ModelMap modelMap) {
		return "redirect:/mobile/main.html";
	}

}